#pragma once

#include	<Net.h>
#include	<Singleton.h>
#include	<map>

#define		GService CenterService::Instance()

class CenterService : public IBaseService, public ISingleton<CenterService> {
public:
	CenterService() : IBaseService("center"), _checkAccount(false) {}
	virtual ~CenterService() {}

	virtual void OnReceive(Sender * sender, Protocol * msg) override;
	virtual void OnClose(Sender * sender, ENet::Close reason) override;

	inline void CheckAccount(bool need) { _checkAccount = need; }
	inline bool NeedCheckAccount() const { return _checkAccount; }

	void SendAllGame(int pf, const google::protobuf::Message & msg);

	void AfterZone_Active(Protocol * msg);
	void AfterZone_Create(Protocol * msg);
	void AfterZone_Rename(Protocol * msg);

	void AfterDB_RoleList(Protocol * msg);
	void AfterDB_Role(Protocol * msg);
	
private:
	bool _checkAccount;
};
